studentListForm = function(){
	Ext.define('studentModel',{
		extend:'Ext.data.Model',
		fields:[ 
		        	{name:'id',type:'String'},
		        	{name:'studentId',type:'String'},
		        	{name:'studentName',type:'string'},
		        	{name:'sex',type:'string'},
		        	{name:'grade',type:'String'},
			        {name:'academy',type:'string'},
			        {name:'professional',type:'string'},
			        {name:'inclass',type:'string'},
			        {name:'counselor',type:'string'},
			        {name:'national',type:'string'},
			        {name:'politicalStatus',type:'string'}
			       ],
		idProperty : 'studentId'
	});
	

	var store = Ext.create('Ext.data.Store',{
		pageSize:100,
		model:studentModel,
		autoLoad:true,
		proxy:{
			type:'ajax',
			url:'searchAllStudentListPageAction.action',
			reader:{
				type:'json',
				root:'resultList.list',
				totalProperty:'resultList.total'
			}
		}
	});
	var sex = getStaticDataStore('sex');
	var national = getStaticDataStore('national');
	var political = getStaticDataStore('political status');
	var grade = getStaticDataStore('grade');
	var  academy= getStaticDataStore('academy');
	var professional = getStaticDataStore('professional');
	var inclass = getStaticDataStore('in class');
	
	//学号
	var CstudentId ={
			width: 200,
			xtype: 'textfield',
			id: 'CstudentId',
			labelWidth:60,
			fieldLabel: '学号'	
		}
	//姓名
	var CstudentName ={
			width: 200,
			xtype: 'textfield',
			id: 'CstudentName',
			labelWidth:60,
			fieldLabel: '姓名'	
		}
	//性别

	var Csex = new Ext.form.ComboBox({
        fieldLabel: '性别',width: 200,
        store: sex,
        displayField: 'valueName',
        valueField: 'valueName',
        triggerAction: 'all',
        labelWidth:60,
        id:'Csex'
       	 });
	//民族
	//nationalS = getStaticDataStore("prom");
	var Cnational = new Ext.form.ComboBox({
        fieldLabel: '民族',width: 200,
        store: national,
        displayField: 'valueName',
        valueField: 'valueName',
        triggerAction: 'all',
        labelWidth:60,
        id:'Cnational'
       	 });
	//政治面貌
	var Cpolitical = new Ext.form.ComboBox({
        fieldLabel: '政治面貌',width: 200,
        store: political,
        displayField: 'valueName',
        valueField: 'valueName',
        triggerAction: 'all',
        labelWidth:60,
        id:'Cpolitical'
       	 });
	//年级
	var Cgrade = new Ext.form.ComboBox({
        fieldLabel: '年级',width: 200,
        store: grade,
        displayField: 'valueName',
        valueField: 'valueId',
        triggerAction: 'all',
        labelWidth:60,
        id:'Cgrade'
       	 });
	//学院
	var Cacademy = new Ext.form.ComboBox({
        fieldLabel: '学院',width: 200,
        store: academy,
        displayField: 'valueName',
        valueField: 'valueName',
        triggerAction: 'all',
        labelWidth:60,
        id:'Cacademy'
       	 });
	//专业
	var Cprofessional = new Ext.form.ComboBox({
        fieldLabel: '专业',width: 200,
        store: professional,
        displayField: 'valueName',
        valueField: 'valueName',
        triggerAction: 'all',
        labelWidth:60,
        id:'Cprofessional'
       	 });
	//班级
	var Cinclass = new Ext.form.ComboBox({
        fieldLabel: '班级',width: 200,
        store: inclass,
        displayField: 'valueName',
        valueField: 'valueName',
        triggerAction: 'all',
        labelWidth:60,
        id:'Cinclass'
       	 });
	//辅导员
	var CteacherName ={
			width: 200,
			xtype: 'textfield',
			id: 'CteacherName',
			labelWidth:60,
			fieldLabel: '辅导员'	
		}
	var rowmn = {
		       //columnWidth: .30,
		       // height:150,
		        layout: 'form',
		        xtype:'panel',
		        border:false,
		       // style:'margin-left:50px;margin-top:50px',
		       /* fieldDefaults: {
			        labelWidth:40,
			        anchor: '100%'
			    },*/
		      
		        items: [{
		        	//layout: 'column',
		        	region:'center',
		    		layout: {
		    		    type: 'hbox',
		    		    align: 'middle ',
		    		    pack: 'center'
		    		},
			        xtype:'panel',
			        border:false,
			        items:[ CstudentId,
							CstudentName,
							Csex,
							Cnational
						]
		        },{
		        	//layout: 'column',
		        	region:'center',
		    		layout: {
		    		    type: 'hbox',
		    		    align: 'middle ',
		    		    pack: 'center'
		    		},
			        xtype:'panel',
			        border:false,
			        items:[Cpolitical,
							Cgrade,
							Cacademy,
							Cprofessional
						]
		        },{//layout: 'column',
		        	region:'center',
		    		layout: {
		    		    type: 'hbox',
		    		    align: 'middle ',
		    		    pack: 'center'
		    		},
			        xtype:'panel',
			        border:false,
			        items:[Cinclass,
							CteacherName
						]}
					
				]
			};
	var condiction = Ext.create('Ext.FormPanel', {
	    title: '查询条件',
	    layout: 'form',
	    frame: true,
	   
	    width: '100%',
	    id:"condition",
	   // renderTo:'form-ct',
	    bodyPadding: 10,
	    items: [
rowmn
	    ],
	    buttons: [{
	        text: '查询',
	        handler: function(){
	        	var CstudentId = Ext.getCmp('CstudentId').getValue();
	        	var CstudentName = Ext.getCmp('CstudentName').getValue();
	        	var Csex = Ext.getCmp('Csex').getValue();
	        	var Cnational = Ext.getCmp('Cnational').getValue();
	        	var Cpolitical = Ext.getCmp('Cpolitical').getValue();
	        	var Cgrade = Ext.getCmp('Cgrade').getValue();
	        	var Cacademy = Ext.getCmp('Cacademy').getValue();
	        	var Cprofessional = Ext.getCmp('Cprofessional').getValue();
	        	var Cinclass = Ext.getCmp('Cinclass').getValue();
	        	var CteacherName = Ext.getCmp('CteacherName').getValue();
	        	
	        	//var str = "role:"+role;
	        	store.load({
	        		
      		      params:{
      		    	  page:0,
      		    	  limit:0,
      		    	  studentId:CstudentId,
      		    	  studentName:CstudentName,
	      		    	sex:Csex,
	      		    	national:Cnational,
	      		    	politicalStatus:Cpolitical,
	      		    	grade:Cgrade,
	      		    	academy:Cacademy,
	      		    	professional:Cprofessional,
	      		    	inclass:Cinclass,
	      		    	counselor:CteacherName,
      		    	  
      		      },   //参数
      		           // callback是加载完毕时执行的回调函数，它包含3个参数：records参数表示获得的数据，
      		         // options表示执行load()时传递的参数，success表示是否加载成功。
      		      callback: function(records, options, success){
      		                 //Ext.Msg.alert('info', '加载完毕');
      		        },
      		       scope: store,       //Scope用来指定回调函数执行时的作用域
      		       add: false             //Add为true时，load()得到的数据会添加在原来的store数据的末尾，
      		                                    //否则会先清除之前的数据，再将得到的数据添加到store中
	        	});
	        }
	    },{
	        text: '重置',
	        handler: function(){
	           // fp.getForm().reset();
	        	Ext.getCmp('condition').form.reset();
	        }
	    }],
	    buttonAlign : "center"
	});
	
	var checkBox = Ext.create('Ext.selection.CheckboxModel');

	
	
	var importStudentForm=new Ext.FormPanel({ 
		title:'上传新文件',
	   // id:'uploadForm', 
	   // anchor:'100%',	    
	    frame:true, 
	    fileUpload: true,   
	    autoHeight:true, 
	    //labelWidth:50, 
	    enctype: 'multipart/form-data',  
	    defaults:{ 
	        anchor: '90%', 
	        allowBlank: false 
	    }, 
	    items:[ 
	        { 
	            xtype:'fileuploadfield', 
	            emptyText: '请选择上传文件...',  
	            fieldLabel: '文件',  
	           // id:'uploadFile', 
	            name: 'file',  
	            allowBlank: false,    
	            blankText: '文件名称不能为空.',    
	            buttonConfig: { 
	                        text: '选择...'
	              } 
	        } 
	    ], 
	    buttons: [{ 
	                    text: '上传', 
	                    handler: function(){ 
	                        if(importStudentForm.getForm().isValid()){ 
	                        	importStudentForm.getForm().submit({ 
	                                url:'importStudentsAction.action', 
	                                method:'POST', 
	                                waitTitle: '请稍后', 
	                                waitMsg: '正在上传文档文件 ...', 
	                                success: function(fp, action){ 
	                                    Ext.MessageBox.alert('信息', "成功导入"+action.result.successNum+"条数据，失败"+action.result.failureNum+"条数据");   
	                                    importTeacherForm.getForm().reset();         // 指定文件字段的id清空其内容  
	                                    store.load(); 
	                                }, 
	                                failure: function(fp, action){ 
	                                    Ext.MessageBox.alert('警告', "第"+action.result.msg+"行数据异常");   
	                                } 
	                            }); 
	                        } 
	                    } 
	                },{ 
	                    text: '重置', 
	                    handler: function(){ 
	                    	importTeacherForm.getForm().reset(); 
	                    } 
	                }],
	    buttonAlign:'center'
	       
	});
	
	
	var grid = Ext.create('Ext.grid.Panel',{
		store:store,	
		columnLines:true,
		selModel:checkBox,
		disableSelection:false,
		//width:600,
		id:"grid11",
		loadMask:true,
		plugins:[  
	             Ext.create('Ext.grid.plugin.RowEditing',{
	            	// pluginId:'newEdit',
	            	 saveBtnText: '确定', 
	                 cancelBtnText: "取消"
	             })  
	    ],
		columns:[
		         {text:'学号',width:100,dataIndex:'studentId',sortable:true},
		         {text:'姓名',width:100,dataIndex:'studentName',sortable:true,editor:{allowBlank : false}},
		         {text:'性别',width:50,dataIndex:'sex',sortable:true,
		        	 editor:{
	     			    	xtype:'combobox',
	     			    	alias:'widget.lifechannelCombo',
	     			        width: 100,
	     			        store: sex,
	     			        displayField: 'valueName',
	     			        valueField: 'valueName',
	     			        triggerAction: 'all',
	     			        queryMode:'local', 
	     			   //    allowBlank : false
		        		 },renderer:function(v){
		        			 var index = sex.find('valueId',v); 
		        			 if(index != -1){
		        				 var r = sex.getAt(index);
		        				 return r.get("valueName");
		        			 }
		        			 else{
		        				 return v;
		        			 }
		        		 }},
		         {text:'民族',width:50,dataIndex:'national',sortable:true,
		        	 editor:{
	     			    	xtype:'combobox',
	     			    	alias:'widget.lifechannelCombo',
	     			        width: 50,
	     			        store: national,
	     			        displayField: 'valueName',
	     			        valueField: 'valueName',
	     			        triggerAction: 'all',
	     			        queryMode:'local', 
	     			       allowBlank : false
		        		 },renderer:function(v){
		        			 var index = national.find('valueId',v); 
		        			 if(index != -1){
		        				 var r = national.getAt(index);
		        				 return r.get("valueName");
		        			 }
		        			 else{
		        				 return v;
		        			 }
		        		 }},
		         {text:'政治面貌',width:100,dataIndex:'politicalStatus',sortable:true,
		        	 editor:{
	     			    	xtype:'combobox',
	     			    	alias:'widget.lifechannelCombo',
	     			        width: 100,
	     			        store: political,
	     			        displayField: 'valueName',
	     			        valueField: 'valueName',
	     			        triggerAction: 'all',
	     			        queryMode:'local', 
	     			       allowBlank : false
		        		 },renderer:function(v){
		        			
		        			 var index = political.find('valueId',v); 
		        			 if(index != -1){
		        				 var r = political.getAt(index);
		        				 return r.get("valueName");
		        			 }
		        			 else{
		        				 return v;
		        			 }
		        		 }
		        		 },
		         {text:'年级',width:80,dataIndex:'grade',sortable:true,editor:{
  			    	xtype:'combobox',
 			    	alias:'widget.lifechannelCombo',
 			        width: 100,
 			        store: grade,
 			        displayField: 'valueName',
 			        valueField: 'valueName',
 			        triggerAction: 'all',
 			        queryMode:'local', 
 			      // allowBlank : false
        		 },renderer:function(v){
        			 var index = grade.find('valueId',v); 
        			 if(index != -1){
        				 var r = grade.getAt(index);
        				 return r.get("valueName");
        			 }
        			 else{
        				 return v;
        			 }
        		 }},
		         {text:"学院",width:100,dataIndex:'academy',sortable:true,
		        	 editor:{
	     			    	xtype:'combobox',
	     			    	alias:'widget.lifechannelCombo',
	     			        width: 100,
	     			        store: academy,
	     			        displayField: 'valueName',
	     			        valueField: 'valueName',
	     			        triggerAction: 'all',
	     			        queryMode:'local', 
	     			       allowBlank : false
		        		 },renderer:function(v){
		        			 var index = academy.find('valueId',v); 
		        			 if(index != -1){
		        				 var r = academy.getAt(index);
		        				 return r.get("valueName");
		        			 }
		        			 else{
		        				 return v;
		        			 }
		        		 }},
		         {text:"专业",width:120,dataIndex:'professional',sortable:true,
				        	 editor:{
			     			    	xtype:'combobox',
			     			    	alias:'widget.lifechannelCombo',
			     			        width: 120,
			     			        store: professional,
			     			        displayField: 'valueName',
			     			        valueField: 'valueName',
			     			        triggerAction: 'all',
			     			        queryMode:'local', 
			     			    //   allowBlank : false
				        		 },renderer:function(v){
				        			 var index = professional.find('valueId',v); 
				        			 if(index != -1){
				        				 var r = professional.getAt(index);
				        				 return r.get("valueName");
				        			 }
				        			 else{
				        				 return v;
				        			 }
				        		 }},
		         {text:'班级',width:120,dataIndex:'inclass',sortable:true,editor:{
  			    	xtype:'combobox',
 			    	alias:'widget.lifechannelCombo',
 			        width: 120,
 			        store: inclass,
 			        displayField: 'valueName',
 			        valueField: 'valueName',
 			        triggerAction: 'all',
 			        queryMode:'local', 
 			      // allowBlank : false
        		 },renderer:function(v){
        			 var index = inclass.find('valueId',v); 
        			 if(index != -1){
        				 var r = inclass.getAt(index);
        				 return r.get("valueName");
        			 }
        			 else{
        				 return v;
        			 }
        		 }},
		         {text:'辅导员',width:80,dataIndex:'counselor',sortable:true,editor:{allowBlank : true}},
		         ],
		autoHeight:true,
		authWidth:true,

		title:"学生列表",
		loadMask:true,
		pageSize:5,
		dockedItems:[{
			dock:'top',
			xtype:'toolbar',
			//height:200,
			items:[{
				width:300,
				fieldLabel:'搜索',
				labelWidth:70,
				xtype:'searchfield',
				store:store			
			},{
				xtype:'label',
				html:'<div style="font-size:12px;color:red">*支持姓名和学号的模糊查询</div>'
			},'->',{
				text:'Excel导入',
				iconCls:'applicationOsxGet',
				xtype:'button',
				handler:function(){
					var importStudentWindow = Ext.create('Ext.Window',{
						layout:'fit',
						width:400,
						height:200,
						closeAction:'hide',
						plain:true,
						resizable : false,
						title:'excel导入',
						items:importStudentForm,
						plain:true
						
					});
					importStudentWindow.show();
				}
			},{
				text:'查看详情',
				iconCls:'Add',
				xtype:'button',
				handler:function (){
					var selectedKeys = grid.getSelectionModel().getSelection();
					if(selectedKeys.length == 0){
						Ext.Msg.alert("提示", "请选中一条记录！");
						return;
					}
					showStudentDetail(selectedKeys[0]);
				}
			},{
				text:'新增',
				iconCls:'Add',
				xtype:'button',
				handler:addOne
			},'-',{
				text:'删除',
				iconCls:'Decline',
				xtype:'button',
				handler:otherDelete
			},'-',
			{
				text:'提交数据',
				iconCls:'Applicationform',
				xtype:'button',
				handler:alter
			}]		
		},
		{
			dock:'bottom',
			xtype:'pagingtoolbar',	
			store:store,
			displayInfo:true,
			displayMsg:'显示{0}-{1}条，共计{2}条',
			emptyMsg:"没有数据"
		},{
			dock:'bottom',
			xtype:'label',
			html:'<div style="font-size:12px;color:red">1.双击进行单行编辑&nbsp&nbsp2.编辑或新增后需要提交数据进行保存&nbsp&nbsp3.登录账号不能重复，输入后会验证</div>'
		},{
            xtype: 'panel',
            dock: 'bottom',
            items: [
                Ext.create('Ext.ux.exporter.Button', {
                    component: Ext.getCmp('grid'),
                    text: "导出 Excel"
                })
            ]
        }]
	});
	
	function addOne(){ 
		var newstore ={
			studentId:'请输入学号',
			studentName:'请输入姓名',
			sex:'男',
			national:'汉',
			politicalStatus:'群众',
	        academy:'计算机学院'
		};
		
	    store.insert(0,newstore);
	    var edit = grid.editingPlugin;
	    edit.startEdit(0,1);
	}
	function otherDelete() {  
	    var data = grid.getSelectionModel().getSelection();  
	    if (data.length == 0) {  
	        Ext.Msg.alert("提示","请先选择要操作的行");  
	        return;  
	    } else {  
	        Ext.Msg.confirm("请确认", "是否真的要删除数据？", function(button, text) {  
	            if (button == "yes") {  
	                var studentIds = [];  
	                Ext.Array.each(data, function(record) {  
	                            var studentId=record.get('studentId');  
	                            //如果删除的是幻影数据，则id就不传递到后台了，直接在前台删除即可  
	                            if(studentId){  
	                            	studentIds.push(studentId);  
	                            } 
	                            else{
	                            	store.remove(record);
	                            }
	                        });
	                //Ext.Msg.alert(teacherIds);
	                if(studentIds.length==0){return;}
	                Ext.Ajax.request({  
	                    url : 'deletStudentInfoByStudentIdsAction.action',  
	                    params : {  
	                    	studentIds : studentIds.join(',')  
	                    },  
	                    method : 'POST',  
	                    success : function(response, opts) {  
	                        var success = Ext.decode(response.responseText).success;  
	                        // 当后台数据同步成功时  
	                        if (success) {  
	                           /* Ext.Array.each(data, function(record) {  
	                                        store.remove(record);// 页面效果  
	                                    });  */
	                        	Ext.Msg.alert("提示","删除成功！");
	                        	store.load();
	                        } else {  
	                        	Ext.Msg.alert("提示","删除失败！");
	                        }  
	                    }  
	                });  
	            }  
	        });  
	    }  
	}  

	function alter() { 
	    var records = store.getUpdatedRecords();// 获取修改的行的数据，无法获取幻影数据  
	    var phantoms=store.getNewRecords( ) ;//获得幻影行  
	    records=records.concat(phantoms);//将幻影数据与真实数据合并  
	    if (records.length == 0) {  
	    	Ext.Msg.alert("提示","没有数据需要提交");   
	        return;  
	    } else {  
	        Ext.Msg.confirm("请确认", "是否真的要修改数据？", function(button, text) {  
	            if (button == "yes") {  
	                var data = [];  
	                Ext.Array.each(records, function(record) {
	                	//Ext.Msg.alert(record.data.teacherName);
	                    data.push(record.data);  
	                    });
	                Ext.Ajax.request({  
	                    url : 'updateStudentListAction.action',  
	                    params : {  
	                    	studentInfoListStr : Ext.encode(data)  
	                    },  
	                    method : 'POST',  
	                    success : function(response, opts) {  
	                        var success = Ext.decode(response.responseText).success;  
	                        // 当后台数据同步成功时  
	                        if (success) {  
	                        	store.load();
	                            Ext.Msg.alert("提示","提交成功");
	                        } else {  
	                            Ext.Msg.alert("提示",Ext.decode(response.responseText).msg); 
	                        }  
	                    }  
	                });  
	            }  
	        });  
	    }  
	} 
	function accountValidator(v){
		var text = Ext.getCmp('accountText');
		if(v!= "" && text.isDirty()){
			Ext.Ajax.request({  
	            url : 'searchTeacherByNameAction.action',  
	            params : {  
	            	userName :  v
	            },  
	            method : 'POST',  
	            success : function(response, opts) {  
	                var success = Ext.decode(response.responseText).success;  
	                if (success) {  
	                	var result = Ext.decode(response.responseText).isOk;
	                	if(result){
	                		text.clearInvalid();
	                		return true;
	                	}
	                	else{
	                		text.markInvalid('用户名已被使用');
	                		return false;
	                	}
	                } 
	                else {  
	                	Ext.Msg.alert("提示","系统错误");
	                	return false;
	                }  
	            }  
	        }); 
		}
		
		return true;
			
	}
	
	function showStudentDetail(data){
		var tabId = "studentDetails" + data.get('studentId');
		var tab = center.queryById(tabId);
	        if (!tab) {
	        	var funActive = eval('new studentInformation('+data.get('studentId')+')');
	        	var tab = center.add({
	        		id: tabId,
	        		iconCls: 'Bookopen',       
	        		xtype: "panel",
	        		title: data.get('studentName'),
	        		closable: true,
	        		//maskDiabled: true,
	        		frame: true,
	        		autoScroll : true,
	        		//baseCls:'allBackImage',
	        		bodyStyle: 'background:white;',
	        			items:funActive
	        	});
	        	
	        }
	       /* var remark = data[0].get("remark")==''?'无':data[0].get("remark");
	        Ext.getCmp(tabId).update('<div style="width:90%;padding-left:80px"><h2 style="text-align:center">'+data[0].get("title")+'</h2>'+
 	        		'<div style="text-align:center">创建时间：'+data[0].get("createDate").replace("T"," ")+'</div>'+
 	        		'<div style="font-size:15px;text-indent:2em">'+data[0].get("contentText")+'</div>'+
 	        		'<div style="font-size:15px;text-align:right"><br></div><br><br><br><br><br>'+
 	        		'<div style="font-size:10px">备注：'+remark+'</div>'+'</div>');*/
    	center.setActiveTab(tabId);
	}
	
	var panel = Ext.create('Ext.panel.Panel',{
		//enableTabScroll: true,
		width:'100%',
		height:400,
		autoScroll : true,
		//x:100,
		//layout: 'column',
       // layout: 'border',
		//margin:'2 10 3 10',
		//title:"kkkkkk",
		region:'center',
		/*layout: {
		    type: 'hbox',
		    align: 'middle ',
		    pack: 'center'
		},*/
		/*layout:{    
			align: 'center',
            type:'table',//表格布局    
            columns:2 //设置表格布局默认列数为2列    
        },*/ 
       items: [condiction,grid],
        listeners: {
            'afterrender': function () {
         	  // Ext.Msg.alert("ss",store.first().get('studentId'));           	
            }
        }
	});
	return panel;
	
	
}